//2019-3-6
//幼小清
$(function() {
  $(document).scroll(function() {
    let Goal = $(".RollingGoal")
    GoalH = Goal.height() * 0.7
    let scroH = $(document).scrollTop()
    if (scroH > GoalH) {
      Goal.addClass("on")

      Goal.find(".CenterBackBtn img").attr(
        "src",
        require["config"]["http_url"] + "/map/images/return_black.png"
      )
      Goal.find(".CenterHeaderSetting img").attr(
        "src",
        require["config"]["http_url"] + "/map/images/setting_black.png"
      )
    } else {
      Goal.removeClass("on")
      Goal.find(".CenterBackBtn img").attr(
        "src",
        require["config"]["http_url"] + "/map/images/return.png"
      )
      Goal.find(".CenterHeaderSetting img").attr(
        "src",
        require["config"]["http_url"] + "/map/images/setting.png"
      )
    }
  })

  var unSelected = "#ccc"
  var selected = "#000"
  $("select").css("color", unSelected)
  $("option").css("color", selected)
  $("select").change(function() {
    var selItem = $(this).val()
    if (
      selItem ==
      $(this)
        .find("option:first")
        .val()
    ) {
      $(this).css("color", unSelected)
    } else {
      $(this).css("color", selected)
    }
  })

  $(document).on("click", ".TabUl li", function() {
    let that = $(this)
    that.siblings().removeClass("on")
    that.addClass("on")
    let index = that.index() + 1
    let div = that.parents(".TabUl").siblings(".TabDivList")
    div.find(".TabDiv").removeClass("on")
    div.find(".TabDiv:nth-child(" + index + ")").addClass("on")
  })
})
//图片获取显示
function ShowImage() {
  $("input[type='file']").on("change", function() {
    var _thisId = $(this).attr("id")
    var objUrl = getObjectURL(this.files[0]) //获取图片的路径，该路径不是图片在本地的路径
    if (objUrl) {
      $("." + _thisId).attr("src", objUrl) //将图片路径存入src中，显示出图片
    }
  })
  //建立一個可存取到該file的url
  function getObjectURL(file) {
    var url = null
    if (window.createObjectURL != undefined) {
      // basic
      url = window.createObjectURL(file)
    } else if (window.URL != undefined) {
      // mozilla(firefox)
      url = window.URL.createObjectURL(file)
    } else if (window.webkitURL != undefined) {
      // webkit or chrome
      url = window.webkitURL.createObjectURL(file)
    }
    return url
  }
}
// (function () {
//   $(document).on("click", "td", function (e) {
//     // e.preventDefault();
//     var val = "";
//     var that = $(this);
//     var obj = that[0];
//     var $pay = $('#pay');
//     val = $pay.val() + that.html();
//     if (obj.className === "pay-del") {
//       val = $pay.val().substring(0, $pay.val().length - 1);
//     } else if (obj.className === "all-pay-o") {
//       return 0;
//     }
//     $pay.val(val);
// 	var pay_val=$('#pay').val();

// 	$('#total').html(pay_val);
//   });
//   //禁用手机自带键盘的弹出
//   $("#pay").focus(function () {
//     document.activeElement.blur();
//   });
// })();
